/**
 * 
 */
package org.apache.hadoop.io;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * @author tim
 */
public class IntWritable implements WritableComparable {
	protected int i;
	public IntWritable(int i) {
		this.i = i;
	}

	public void readFields(DataInputStream in) throws IOException {
		i=in.readInt();
	}

	public void write(DataOutputStream out) throws IOException {
		out.writeInt(i);
	}
	
	public int get() {
		return i;
	}

	public int compareTo(Object o) {
		IntWritable t = (IntWritable) o;
		if (i==t.get()) return 0;
		if (i<t.get()) return -1;
		return 1;
	}
	
	@Override
	public String toString() {
		return "" + i;
	}
	
}